package com.decent.common.bo;

import com.decent.common.enums.ErrorCodeEnum;
import com.decent.common.enums.sms.SmsErrorCodeEnum;
import lombok.Data;

import java.io.Serializable;

/**
 * 接口简易返回信息
 *
 * @author wangyan
 */
@Data
public class SimpleMessage implements Serializable {
    private static final long serialVersionUID = -2957516153008725933L;
    private Integer code;
    private String message;

    public SimpleMessage() {
    }

    public SimpleMessage(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public SimpleMessage(ErrorCodeEnum code) {
        this.code = code.getCode();
        this.message = code.getMessage();
    }

    public SimpleMessage(SmsErrorCodeEnum code) {
        this.code = code.getCode();
        this.message = code.getMessage();
    }

    public SimpleMessage(ErrorCodeEnum code, String message) {
        this.code = code.getCode();
        this.message = message;
    }

    public static SimpleMessage no(String message) {
        return new SimpleMessage(ErrorCodeEnum.NO, message);
    }

    public static SimpleMessage no() {
        return new SimpleMessage(ErrorCodeEnum.NO);
    }

    public static SimpleMessage ok(String message) {
        return new SimpleMessage(ErrorCodeEnum.OK, message);
    }

    public static SimpleMessage ok() {
        return new SimpleMessage(ErrorCodeEnum.OK);
    }
}
